package edu.bit.water.controller;

import edu.bit.water.entity.WasteWaterTable1;
import edu.bit.water.entity.WasteWaterEva;
import edu.bit.water.service.EntityEffluentLetService;
import edu.bit.water.view.EntityEffluentLetParams;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;
import java.util.Map;

/**
 * 废水排放实体表Controller层
 *
 * @author HuJiShuang
 * @Date 19.07.11
 */
@Controller
@RequestMapping(value = "/entity_effluent_let")
public class EntityEffluentLetController {

    @Autowired
    private EntityEffluentLetService entityEffluentLetService;

    /**
     * @return 返回元数据表中包含的英文名称和中文名称
     */
    @ResponseBody
    @RequestMapping(value = "/select/table/column", method = RequestMethod.GET)
    public String selectTableColumn() {
        return entityEffluentLetService.selectTableColumn();
    }

    /**
     * @param entityEffluentLetParams 该参数包含一系列键值对，key：字段英文名称，value：值
     * @return 结果
     */
    @ResponseBody
    @RequestMapping(value = "/insert", method = RequestMethod.POST)
    public String insert(@RequestBody EntityEffluentLetParams entityEffluentLetParams) {
        return entityEffluentLetService.insert(entityEffluentLetParams);
    }

    /**
     * @return 返回实体表中的记录
     */
    @ResponseBody
    @RequestMapping(value = "/select/all", method = RequestMethod.GET)
    public String selectAll(WasteWaterEva waterEva) {
        //waterEva.showContent();
        return entityEffluentLetService.selectAll(waterEva.getId());
    }

    /**
     * @param idList 要删除记录的集合
     * @return
     */
    @ResponseBody
    @RequestMapping(value = "/delete", method = RequestMethod.POST)
    public String delete(@RequestBody List<Integer> idList) {
        return entityEffluentLetService.delete(idList);
    }

    /**
     * @param entityEffluentLetParams 该类中有两个属性一个是id(对应着实体表id)，一个map用来传递多个键值对
     * @return
     */
    @ResponseBody
    @RequestMapping(value = "/update")
    public String update(@RequestBody EntityEffluentLetParams entityEffluentLetParams) {
        return entityEffluentLetService.update(entityEffluentLetParams);
    }
}
